package com.example.flex.resolver.advice;

import com.example.flex.common.exception.BusinessException;
import com.example.flex.utils.response.BaseResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author: 不是菜鸡爱编程
 * @Date: 2023/11/02/20:23
 * @Description:
 */
@RestControllerAdvice
public class BusinessControllerAdvice {
    /**
     * 业务异常响应
     *
     * @param businessException 业务异常
     * @return {@link BaseResponse}<{@link ?}>
     */
    @ExceptionHandler(BusinessException.class)
    public BaseResponse<?> businessExceptionResponse(BusinessException businessException){
        return BaseResponse.error(businessException.getMessage());
    }
}
